package com.ruoyi.test;


import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class WordReader {
    public static void main(String[] args) {
        try {
            File file = new File("D:\\dev\\RuoYi-Vue-Plus\\ruoyi-admin\\src\\main\\resources\\临沂市财金大数据有限公司.pdf");
            PDDocument document = PDDocument.load(file);

            PDFTextStripper stripper = new PDFTextStripper();
//            stripper.setStartBookmark(0); // 设置起始标记
//            stripper.setEndBookmark(10); // 设置结束标记
            // 去除页眉页脚
            String paragraphStart = stripper.getParagraphStart();
            String paragraphEnd = stripper.getParagraphEnd();
            System.out.println(paragraphStart);
            System.out.println(paragraphEnd);
            String content = stripper.getText(document);
            System.out.println(content);

            document.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
